'''###########################################################################################################################
### File: main_gui.py
### Name: Patrick Delaney, Andrew Oberlin
### Class: CSE 487
### Instructor: Dr.Zmuda
### Assignment: Final Project
### Description: Renders the main gui for the level editor.
################ 
'''
from menu_button import MenuButton
from panda3d.core import Vec2, Point3, Vec3, Vec4
from direct.gui.DirectGui import *
from game_maker_gui import GameMakerGUI
from game_loader import GameLoader

class mainGUI:
	'''
	### Name: __init__ (Constructor)
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: Initializes all the game maker gui, which
					 requires a project name to move on
	'''
	def __init__(self, parent):
		self.parent = parent
		self.models = dict()
		self.__loadModels()
	
	'''
	### Name: loadModels (Constructor)
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: Loads the GUI objects
	'''
	def __loadModels(self):
		self.models['background'] = self.parent.loader.loadModelCopy("models/plane")
		self.backgroundTexture = self.parent.loader.loadTexture("models/gui/game_maker/menu_background.jpg")
		self.models['background'].setTexture(self.backgroundTexture)
		self.models['background'].setTransparency(1)
		self.models['background'].setScale(2.67, 1, 2)
		self.models['background'].reparentTo(self.parent.base.aspect2d)
		
		self.models['logo'] = self.parent.loader.loadModelCopy("models/plane")
		self.logoTexture = self.parent.loader.loadTexture("models/gui/game_maker/main_menu_logo.png")
		self.models['logo'].setTexture(self.logoTexture)
		self.models['logo'].setTransparency(1)
		self.models['logo'].setScale(2.67, 1, 0.35)
		self.models['logo'].setPos(0, 0, 0.75)
		self.models['logo'].reparentTo(self.parent.base.aspect2d)
		
		self.models['game_maker_button'] = MenuButton(self.parent, 'game_maker_button', 'models/gui/game_maker/game_maker_button', 
			self.loadGameMaker, Vec3(-.75, 0, 0), textPos=Vec3(-0.35, 0, .30), isMovie = False, text="Game Maker!")
		#self.models['create_character_button'].hide()
		
		self.models['play_button'] = MenuButton(self.parent, 'create_object_button', 'models/gui/game_maker/play_button', 
			self.loadGameLoader, Vec3(.75, 0, 0), textPos=Vec3(-0.35, 0, .30), isMovie = False, text="Play Your Game!")
		
		self.models['back_button'] = MenuButton(self.parent, 'create_object_button', 'models/gui/game_maker/back_button', 
			self.goBack, Vec3(-.90, 0, -.80),scale=0.25, textPos=Vec3(-0.20, 0, .15), isMovie = False, text="Go Back")
	'''
	### Name: hide
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: hides this GUI
	'''
	def hide(self):
		for key in self.models.keys():
			self.models[key].hide()
	
	'''
	### Name: show
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: show this GUI
	'''
	def show(self):
		for key in self.models.keys():
			self.models[key].show()
	
	def loadGameMaker(self):
		self.hide()
		self.gameMakerGUI = GameMakerGUI(self.parent, self)
		
	def loadGameLoader(self):
		self.hide()
		self.gameLoader = GameLoader(self.parent, self)
	'''
	### Name: goBack
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: goes back to the previous GUI
	'''
	def goBack(self):
		self.hide()
		self.parent.titlescreen.show()
		self.parent.accept("enter", self.parent.startMainGUI)